package com.mco.controller;

import com.mco.entity.Customer;
import com.mco.entity.User;
import com.mco.service.CustomerService;
import com.mco.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author ：liao.wei
 * @description ： 消费者接口
 * @date ：2023/9/15 18:33
 */
@RequiredArgsConstructor
@RestController
@RequestMapping(path = "/customer")
public class CustomerController {
	
	private final CustomerService customerService;
	
	/**
	 * 新增
	 *
	 */
	@PostMapping("add")
	public void addCustomer() {
		for (int i = 0; i < 3; i++) {
			Customer customer = new Customer();
			customer.setAge(18 + i);
			customer.setCname("lisi" + i);
			customer.setBirth("1999-09-09");
			customer.setPhone("1234567809" + i);
			customer.setSex(i);
			customerService.addCustomer(customer);
		}
		
	}
	
	/**
	 * 查询
	 *
	 * @param id 参数
	 * @return Customer
	 */
	@GetMapping("find/{id}")
	public Customer find(@PathVariable Long id) {
		return customerService.find(id);
	}
}
